﻿/**
 * 
 * Copyright 2009 Mike Jamer [email: mikejamer@gmail.com ]
 * 
 * This File is part of Moose IRC
 * 
 * MooseIRC is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * MooseIRC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with MooseIRC.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace moose.irc
{
    /// <summary>
    /// base MooseIRC Action
    /// </summary>
    [CLSCompliant(true)]
    public abstract class IrcAction : object
    {
        /// <summary>
        /// returns valid states for this action to execute correctly
        /// </summary>
        /// <returns>possible states for this to execute correctly</returns>
        protected abstract IrcState valid_states();

        /// <summary>
        /// Execute Action
        /// </summary>
        /// <param name="client">Exposes pretty much everything, have fun</param>
        /// <param name="input">action input, action name, parmeters etc</param>
        public void execute(IrcClient client, IrcMessage input)
        {
            if ((valid_states() & client.SessionState) == client.SessionState)
            {
                action(client, input);
            }
            else
            {
                //TODO: Throw Exception, or quietly log
            }
            return;
        }

        /// <summary>
        /// Action Code
        /// </summary>
        /// <param name="client">reference to client</param>
        /// <param name="input">action input, action name, parmeters etc</param>
        protected abstract void action(IrcClient client, IrcMessage input);

    }
}
